package afss.freesky.data.conn;

import java.sql.DriverManager;

/**
 * 
 * @author Jacky@AFSS, 2012
 *
 */
public class DBSql2k8Bean extends DBConnBean {
	/**
	 *
	 */
	private static final long serialVersionUID = -4451777563654845691L;
	public static String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
	public static String URL = "jdbc:sqlserver://localhost\\sqlexpress:1433;DatabaseName=FS_SAB";
	public static String USER = "sab";
	public static String PASSWORD = "sab";

	public DBSql2k8Bean() {
		super();
	}

	/*
	 * @see afss.freesky.common.db.IDBConn#getConnection()
	 */

	public void getConnection() {
		try {
			Class.forName(DRIVER).newInstance();
			conn = DriverManager.getConnection(URL, USER, PASSWORD);
		} catch (java.lang.ClassNotFoundException ce) {
			logger.error("Get Connection error:", ce);
		} catch (java.sql.SQLException se) {
			logger.error("Get Connection error:", se);
		} catch (Exception e) {
			logger.error("Get Connection error:", e);
		}
	}

	/*
	 * 
	 * @see afss.freesky.common.db.IDBConn#setDBConnInfo(java.lang.String,
	 * java.lang.String, java.lang.String, java.lang.String)
	 */

	public static void setDBConnInfo(String dbIP, String dbName, String dbUser, String dbPassword) {
		URL = String.format("jdbc:sqlserver://" + dbIP + ":1433;DatabaseName=" + dbName);
		USER = dbUser;
		PASSWORD = dbPassword;
	}
}
